#include "stdafx.h"
#include "Tool.h"

static char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

/*哈希编码*/
std::string hashCoding(const unsigned char* pData, int nSize)
{
	int nStrSize = nSize * 2 + 1;
	char* pStr = new char[nStrSize];
	memset(pStr, 0, nStrSize);

	int nPos = 0;
	for (int i = 0; i < nSize; ++i)
	{
		pStr[nPos] = hex[pData[i] >> 4];
		pStr[nPos + 1] = hex[pData[i] & 0x0F];
		nPos += 2;
	}

	std::string str(pStr);
	delete[] pStr;

	return str;
}